import {useGet, usePost} from "@/utils/request";
import type {API, DynamicObject, IPage, PageParams} from "@/type/type";

export const getMyLessonAPI = (current = 1, pageSize = 5) => {
  return useGet<IPage<API.ILesson>>('/lesson/getByStudent', {current, pageSize})
}

export const listLessonAPI = (params: DynamicObject) => {
  return usePost<API.ILesson[]>('/lesson/list', params)
}

export const pageLessonAPI = (params: PageParams) => {
  return usePost<IPage<API.ILesson>>('/lesson/page', params)
}

export const getLessonAPI = (id: string) => {
  return useGet<API.ILesson>(`/lesson/${id}`)
}

/**
 * 课程预约
 * @param lessonId 课程ID
 */
export const reserveLessonAPI = (lessonId: string) => {
  return usePost<boolean>('/lessonStudent/reserve', {lessonId})
}


/**
 * 取消预约
 * @param lessonId 课程ID
 */
export const cancelLessonAPI = (lessonId: string) => {
  return usePost<boolean>('/student/cancelLesson', {lessonId})
}

/**
 * 签到
 * @param lessonId 课程ID
 * @param password 签到密码
 */
export const signInLessonAPI = (lessonId: string, password: string) => {
  return usePost<boolean>('/student/signInLesson', {lessonId, password})
}
